<template>
  <view class="container">
    <view class="data-list">
      <view class="data-item" v-for="(item, index) in list" :key="index">
        <view class="appointment">
          <text class="region">提现金额：</text>
          <text class="detail">{{ item.money }}</text>
        </view>
        <view class="appointment">
          <text class="region">提现状态：</text>
          <text class="detail">{{ item.status_text }}</text>
        </view>
        <view class="appointment">
          <text class="region">银行名称：</text>
          <text class="detail">{{ item.bank }}</text>
        </view>
        <view class="appointment">
          <text class="region">银行账号：</text>
          <text class="detail">{{ item.account }}</text>
        </view>
        <view class="appointment">
          <text class="region">联系人：</text>
          <text class="detail">{{ item.name }}  {{ item.phone }}</text>
        </view>
      </view>
    </view>
    <empty v-if="!list.length" :isLoading="isLoading" tips="亲，暂无数据" />
	<!-- 底部操作按钮 -->
	<view class="footer-fixed">
	  <view class="btn-wrapper">
	    <view class="btn-item btn-item-main" @click="handleWithdraw()">申请提现</view>
	  </view>
	</view>
  </view>
</template>

<script>
  import * as UserApi from '@/apishop/user/user'
  import * as WithdrawApi from '@/apishop/withdraw'
  import Empty from '@/components/empty'

  export default {
    components: {
      Empty
    },
    data() {
      return {
        //当前页面参数
        options: {},
        // 正在加载
        isLoading: true,
        // 收货地址列表
        list: [],
      }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      // 当前页面参数
      this.options = options
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
      // 获取页面数据
      this.getPageData()
    },

    methods: {

      // 获取页面数据
      getPageData() {
        const app = this
        app.isLoading = true
        app.getDataList()
      },

      // 获取数据列表
      getDataList() {
        const app = this
        return new Promise((resolve, reject) => {
          WithdrawApi.list()
            .then(result => {
              app.list = result.data.list
              resolve(result)
            })
            .catch(reject)
        })
      },

      // 列表排序把默认收货地址放到最前
      onReorder() {
        const app = this
        app.list()
      },
  
	  /**
	   * 跳转申请提现
	   */
	  handleWithdraw() {
		this.$navTo('pages/shop/withdraw/apply')
	  }
    }
  }
</script>

<style lang="scss" scoped>
  // 商品列表
  .data-list {
    padding: 4rpx;
    box-sizing: border-box;
  }
	
  .data-item {
    width: 100%;
    height: 240rpx;
    margin-bottom: 12rpx;
    padding: 20rpx;
    box-sizing: border-box;
    background: #fff;
    line-height: 1.6;
  
    &:last-child {
      margin-bottom: 0;
    }
  }
  
  .data-item_left {
    display: flex;
    width: 200rpx;
    background: #fff;
    align-items: center;
  
    .image {
      display: block;
      width: 140rpx;
      height: 140rpx;
    }
  }
  
  .data-item_right {
    position: relative;
    // width: 450rpx;
    flex: 1;
  
    .status-name {
      margin-top: 10rpx;
      height: 64rpx;
      line-height: 1.3;
      white-space: normal;
      color: #484848;
      font-size: 26rpx;
    }
  }
  
  
  .item-option {
    display: flex;
    justify-content: space-between;
    height: 48rpx;
  }
  
  
  
  // 底部操作栏
  .footer-fixed {
    position: fixed;
    bottom: var(--window-bottom);
    left: 0;
    right: 0;
    height: 96rpx;
    z-index: 11;
    box-shadow: 0 -4rpx 40rpx 0 rgba(144, 52, 52, 0.1);
    background: #fff;
  
    .btn-wrapper {
      height: 100%;
      display: flex;
      align-items: center;
      padding: 0 20rpx;
    }
  
    .btn-item {
      flex: 1;
      font-size: 28rpx;
      height: 72rpx;
      line-height: 72rpx;
      text-align: center;
      color: #fff;
      border-radius: 50rpx;
    }
  
    .btn-item-main {
      background: linear-gradient(to right, #f9211c, #ff6335);
    }
  
  }
  
</style>
